<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
            list-style: none;
        }

        img {
            vertical-align: top;
        }

        /*取消图片底部3像素距离*/
        .box {
            width: 300px;
            height: 200px;
            margin: 100px auto;
            background-color: pink;
            position: relative;
            /*overflow: hidden;*/
        }

        .box ul li {
            float: left;
        }

        .box ul {
            width: 1500px;
            position: absolute;
            left: 0;
            top: 0;
        }
    </style>
</head>
<body>
<div class="box" id="screen">
    <ul>
        <li><img src="images/1.jpg" alt=""/></li>
        <li><img src="images/2.jpg" alt=""/></li>
        <li><img src="images/3.jpg" alt=""/></li>
        <li><img src="images/1.jpg" alt=""/></li>
    </ul>
</div>
<script>
    var screen = document.getElementById("screen");
    var ul = screen.children[0];
    var timer = setInterval(play, 15);
    screen.onmouseover = function () {
        clearInterval(timer);
    };
    screen.onmouseout = function () {
        timer = setInterval(play, 15);
    };

    function play() {
        //leader = leader + step
        var leader = ul.offsetLeft;
        var step = -2;
        if (leader > -900) {
            leader = leader + step;
            ul.style.left = leader + "px";
        } else {
            ul.style.left = 0;
        }
    }
</script>
</body>
</html>